# CMake最低版本号要求
cmake_minimum_required(VERSION 3.15)

# 项目名称
project(earphoneTestToolV3)

# 依赖的头文件
include_directories(${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/include/test-item)

# 文件搜索
file(GLOB SRC "${PROJECT_SOURCE_DIR}/src/*.cpp")
file(GLOB SUBTESTITEM "${PROJECT_SOURCE_DIR}/src/test-item/*.cpp")

# 
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads)

# 设置生成库文件的路径(静态库\动态库都可行)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

# 设置生成可执行文件的路径
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)

# 指定交叉编译器
set(CMAKE_C_COMPILER	${PROJECT_SOURCE_DIR}/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-gcc)
set(CMAKE_CXX_COMPILER	${PROJECT_SOURCE_DIR}/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-g++)
# set(CMAKE_C_COMPILER	gcc)
# set(CMAKE_CXX_COMPILER	g++)

MESSAGE("PROJECT_NAME:${PROJECT_NAME}")
MESSAGE("SRC:${SRC}")
MESSAGE("LIBRARY_OUTPUT_PATH:${LIBRARY_OUTPUT_PATH}")
MESSAGE("EXECUTABLE_OUTPUT_PATH:${EXECUTABLE_OUTPUT_PATH}")

# 生成动态库文件
add_library(${PROJECT_NAME} SHARED ${SRC} ${SUBTESTITEM})

# 生成可执行文件（方式三：链接动态库文件）
## 包含动态库路径
link_directories(${PROJECT_SOURCE_DIR}/lib)
## 生成可执行文件
add_executable(app main.cpp)
## 链接动态库文件(app 依赖动态库earphoneTestToolV3)
target_link_libraries(app earphoneTestToolV3 Threads::Threads)

